package Core_no_tiles;

import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;

import Core_no_tiles.playerTest.Player;
import Engine.Engine;
import Engine.InputHandling.Keyboard;
import Engine.Utils.ImageHandler;
import Engine.Utils.Vector2f;

/**
 * Using the engine without tiles.
 * @author Lueko
 *
 */
public class EngineTest extends Engine {

	private static final long serialVersionUID = 1L;
	
	private BufferedImage background;
	private Player player;
	
	public EngineTest(String title, int width, int height) {
		super(title, width, height);
//		background = ImageHandler.load("/maps/maxresdefault.jpg");
		background = ImageHandler.load("/maps/asdfmap.PNG");
		
//		player = new Player(new Vector2f(50, 50), ImageHandler.load("/entities/character.png"), false);
//		drawables.add(player);
//		updateables.add(player);
		
//		setUpdateCap(120);
//		setMoveViewSpeed(4);
	}
	
	public void cameraMoving() {
		if (Keyboard.keysDown[KeyEvent.VK_D]) mapPos.setX(mapPos.getX() - getMoveViewSpeed());
		if (Keyboard.keysDown[KeyEvent.VK_A]) mapPos.setX(mapPos.getX() + getMoveViewSpeed());
		if (Keyboard.keysDown[KeyEvent.VK_W]) mapPos.setY(mapPos.getY() + getMoveViewSpeed());
		if (Keyboard.keysDown[KeyEvent.VK_S]) mapPos.setY(mapPos.getY() - getMoveViewSpeed());
	}

	int time = 0;
	@Override
	protected void updateStuff() {
		cameraMoving();
		time++;
        if (time >= 60) {
            window.setTitle(window.getRealTitle() + " | " + fps + "fps | " + ups + "ups");
            time = 0;
        }
	}
	
	@Override
	protected void renderStuff(Graphics g) {
//		g.drawImage(background, (int)mapPos.getX(), (int)mapPos.getY(), width, height, null);
		g.drawImage(background, (int)mapPos.getX(), (int)mapPos.getY(), null);
	}
	
	public static void main(String[] args) {
		new EngineTest("EngineTest", 1900, 1000);
	}

}
